package io.renren.modules.demo.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.renren.common.entity.XlsLogThirdpayEntity;
import io.renren.common.entity.XlsUserAwardEntity;
import io.renren.common.enums.CircleLevelEnum;
import io.renren.common.page.PageData;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.demo.dao.XlsLogThirdpayDao;
import io.renren.modules.demo.dto.XlsLogThirdpayDTO;
import io.renren.modules.demo.dto.XlsUserAwardDTO;
import io.renren.modules.demo.service.XlsLogThirdpayService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 第三方支付记录表
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2020-04-16
 */
@Service
public class XlsLogThirdpayServiceImpl extends CrudServiceImpl<XlsLogThirdpayDao, XlsLogThirdpayEntity, XlsLogThirdpayDTO> implements XlsLogThirdpayService {

    @Override
    public QueryWrapper<XlsLogThirdpayEntity> getWrapper(Map<String, Object> params) {

        QueryWrapper<XlsLogThirdpayEntity> wrapper = new QueryWrapper<>();

        return wrapper;
    }

    @Override
    public PageData<XlsLogThirdpayDTO> queryPage(Map<String, Object> params) {
        QueryWrapper<XlsLogThirdpayEntity> wrapper = getWrapper(params);
        if(ObjectUtil.isNotEmpty(params.get("username"))) {
            wrapper.like("xu.username", params.get("username"));
        }
        if(ObjectUtil.isNotEmpty(params.get("outTradeNo"))) {
            wrapper.eq("xlt.out_trade_no", params.get("outTradeNo"));
        }
        IPage<XlsLogThirdpayDTO> page = baseDao.queryPage(
                getPage(params, null, false),
                wrapper
        );

        return getPageData(page, currentDtoClass());
    }

    @Override
    public List<XlsLogThirdpayDTO> queryList(Map<String, Object> params) {
        QueryWrapper<XlsLogThirdpayEntity> wrapper = getWrapper(params);
        if(ObjectUtil.isNotEmpty(params.get("username"))) {
            wrapper.like("xu.username", params.get("username"));
        }
        if(ObjectUtil.isNotEmpty(params.get("outTradeNo"))) {
            wrapper.eq("xlt.out_trade_no", params.get("outTradeNo"));
        }
        List<XlsLogThirdpayDTO> list = baseDao.queryList(
                wrapper
        );

        return list;
    }


}